package com.xinqi.modules.prepare.prepare.controller.web;

import com.xinqi.common.base.response.PageInfo;
import com.xinqi.common.base.response.R;
import com.xinqi.modules.prepare.prepare.dto.req.PrepareOperateLogQueryDTO;
import com.xinqi.modules.prepare.prepare.dto.rsp.PrepareOperateLogResultDTO;
import com.xinqi.modules.prepare.prepare.service.PrepareOperateLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 备课区操作记录表WEB控制层
 *
 * @author: system
 * @date: 2023/03/19
 */
@Tag(name = "Web-备课区-操作日志", description = "备课区-操作日志Web接口")
@RestController
@RequestMapping("/web/prepare")
@RequiredArgsConstructor
public class PrepareOperateLogWebController {
    private final PrepareOperateLogService prepareOperateLogService;

    /**
     * 备课区操作记录表-分页
     */
    @Operation(summary = "备课区操作记录表-分页")
    @GetMapping("/{prepare-id}/operate-log/page")
    public R<PageInfo<PrepareOperateLogResultDTO>> page(@Parameter(description = "备课区id", example = "100001") @PathVariable("prepare-id") Long prepareId,
                                                        @ParameterObject PrepareOperateLogQueryDTO dto) {
        dto.setPrepareId(prepareId);
        PageInfo<PrepareOperateLogResultDTO> page = prepareOperateLogService.page(dto, dto);
        return R.data(page);
    }

    /**
     * 备课区操作记录表-详情
     */
    @Operation(summary = "备课区操作记录表-详情")
    @GetMapping("/{prepare-id}/operate-log/{id}")
    public R<PrepareOperateLogResultDTO> findById(@Parameter(description = "备课区id", example = "100001") @PathVariable("prepare-id") Long prepareId,
                                                  @Parameter(description = "id", example = "100001") @PathVariable("id") Long id) {
        PrepareOperateLogResultDTO dto = prepareOperateLogService.findById(id);
        return R.data(dto);
    }

    /**
     * 还原删除的文件
     */
    @Operation(summary = "还原删除的文件")
    @PutMapping("/{prepare-id}/operate-log/{id}/restore")
    public R<Boolean> restore(@Parameter(description = "id", example = "100001") @PathVariable("id") Long id) {
        return R.data(prepareOperateLogService.restore(id));
    }

    /**
     * 删除备课区操作记录表
     */
//    @Operation(summary = "删除备课区操作记录表")
//    @DeleteMapping("/{id}")
//    public R<Boolean> delete(@Parameter(description = "id", example = "100001") @PathVariable("id") Long id) {
//        return R.data(prepareOperateLogService.deleteById(id));
//    }

}
